<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态组件</title>
</head>
<body>
    <div id="app">
        <button @click="componentId='home'">home</button>
        <button @click="componentId='about'">guanyu</button>
        <button @click="componentId='cat'">fenlei</button>
        <button @click="componentId='mine'">wode</button>

        <component :is="componentId"></component>
    </div>

   
</body>
<script src='../../vue文件/vue.js'></script>
<script>

    let home = {
        template:'<div>主页</div>'
    }
    let about = {
        template:'<div>关于</div>'
    }
    let mine = {
        template:'<div>我的</div>'
    }

    let vm = new Vue({
        el: '#app',
        data: {
             msg:'hello vue.js',
             componentId:'home'
        },
        methods: {},
        components:{
            // home:home,
            // about:about,
            // mine:mine,
            home,
            about,
            mine,
            cat:{
                template:'<div>分类</div>'
            }
        }
    })
</script>
</html>